//
//  HaveFourPicCollectionViewCell.m
//  bh
//
//  Created by lanou on 15/12/24.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "HaveFourPicCollectionViewCell.h"

@implementation HaveFourPicCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        _OnePictureView0 = [[UIImageView alloc]initWithFrame:(CGRectMake(0, 0, kWidth / 5, kWidth / 5))];
        
        _OnePictureView0.backgroundColor = [UIColor yellowColor];
        [self addSubview:_OnePictureView0];
        
        _OnePictureView1 = [[UIImageView alloc]initWithFrame:(CGRectMake(kWidth / 5 +2, 0, kWidth / 5, kWidth / 5))];
        _OnePictureView1.backgroundColor = [UIColor yellowColor];
        [self addSubview:_OnePictureView1];
    
        _OnePictureView2 = [[UIImageView alloc]initWithFrame:(CGRectMake(0, kWidth / 5 +2, kWidth / 5, kWidth / 5))];
        _OnePictureView2.backgroundColor = [UIColor yellowColor];
        [self addSubview:_OnePictureView2];
        
        _OnePictureView3 = [[UIImageView alloc]initWithFrame:(CGRectMake(kWidth / 5 +2, kWidth / 5 +2, kWidth / 5, kWidth / 5))];
        _OnePictureView3.backgroundColor = [UIColor yellowColor];
        [self addSubview:_OnePictureView3];
        
        _titleLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0, kWidth /2.5 - 40, kWidth / 2.5, 25))];
        _titleLabel.textColor = [UIColor cyanColor];
        [self addSubview:_titleLabel];
        
        
    }
    return self;
}



- (void)setPhotos:(Photos *)photos{
    
    self.pictureArray = [[NSMutableArray alloc]init];
    
    if (_photos != photos) {
        _photos = photos;
        for (NSDictionary *dic in photos.items) {
            
            Photos *photos1 =[Photos shareWithDictionary:dic];
            [self.pictureArray addObject:photos1];
        }
        NSLog(@"这个数组%ld",self.pictureArray.count);
        for (int i = 0; i < [self.pictureArray count]; i ++) {
            
            Photos *photo = self.pictureArray[i];
            if (i == 0) {
                [_OnePictureView0 setImageWithURL:[NSURL URLWithString:photo.pic]];
            }
            if (i == 1) {
                
                [_OnePictureView1 setImageWithURL:[NSURL URLWithString:photo.pic]];
            }
            if (i == 2) {
                [_OnePictureView2 setImageWithURL:[NSURL URLWithString:photo.pic]];
            }
            
            if (i == 3) {
                
                [_OnePictureView3 setImageWithURL:[NSURL URLWithString:photo.pic]];
            }
        }
        
        
        
        
        
//        Photos *photos1 = self.pictureArray[0];
//        [_OnePictureView0 setImageWithURL:[NSURL URLWithString:photos1.pic]];
//       
//        Photos *photos2 = self.pictureArray[1];
//        [_OnePictureView1 setImageWithURL:[NSURL URLWithString:photos2.pic]];
//    
//        Photos *photos3= self.pictureArray[2];
//        [_OnePictureView2 setImageWithURL:[NSURL URLWithString:photos3.pic]];
//        
//        Photos *photos4 = self.pictureArray[3];
//        [_OnePictureView3 setImageWithURL:[NSURL URLWithString:photos4.pic]];
        

        
        
        
        _titleLabel.text = photos.title;
        
    }
    
    
    
}









@end
